<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('维修店档案列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 120px;">网点店铺名称：</label>
                                <input id="storeName" type="text" name="storeName"/>
                            </li>
                            <!-- <li>
                                 <label>服务承诺：</label>
                                 <input type="text" name="storeService"/>
                             </li>
                             <li>
                                 <label>店铺浏览量：</label>
                                 <input type="text" name="storePageviews"/>
                             </li>-->
                            <li>
                                <label>详细地址：</label>
                                <input id="storeAddress" type="text" name="storeAddress"/>
                            </li>
                            <li>
                                <label>联系人：</label>
                                <input id="storePerson" type="text" name="storePerson"/>
                            </li>
                            <li>
                                <label>联系方式：</label>
                                <input id="storePhone" type="text" name="storePhone"/>
                            </li>
                            <li>
                                <label>所属大区：</label>
                                <input id="agentName" type="text" name="agentName"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select id="storeState" name="storeState">
                                    <option value="">所有</option>
                                    <option value="1">待审核</option>
                                    <option value="2">通过</option>
                                    <option value="3">驳回</option>
                                </select>
                            </li>

                            <li>
                                <label style="width: 140px;">是否订单管理权：</label>
                                <select id="isRaker" name="isRaker" th:with="type=${@dict.getType('zsyh_yesno')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <!--<li class="select-time">
                                <label>加入时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCreateTime]"/>
                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="zsyh:repairStore:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:repairStore:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:repairStore:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zsyh:repairStore:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:repairStore:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:repairStore:remove')}]];
        var isRakerDatas = [[${@dict.getType('zsyh_yesno')}]];
        var partsCheckDatas = [[${@dict.getType('parts_check')}]];
        var prefix = ctx + "zsyh/repairStore";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                pageSize:7,
                modalName: "电器店档案",
                queryParams: function (params) {
                    var temp ={};
                    if(params){
                        if (params.storeName) {
                            temp.storeName = params.storeName
                        }
                        if (params.storePhone) {
                            temp.storePhone = params.storePhone
                        }
                        if (params.storeAddress) {
                            temp.storeAddress = params.storeAddress
                        }if (params.storePerson) {
                            temp.storePerson = params.storePerson
                        }if (params.agentName) {
                            temp.agentName = params.agentName
                        }if (params.isRaker) {
                            temp.isRaker = params.isRaker
                        }if (params.storeState) {
                            temp.storeState = params.storeState
                        }
                    }
                    temp.storeName = $("#storeName").val();
                    temp.storeState = $("#storeState").val();
                    temp.isRaker = $("#isRaker").val();
                    temp.agentName = $("#agentName").val();
                    temp.storePerson = $("#storePerson").val();
                    temp.storeAddress = $("#storeAddress").val();
                    temp.storePhone =$("#storePhone").val();
                    temp.storeClassify ='3';
                    temp.pageSize =7;
                    temp.pageNum = params.offset / 7 + 1;
                    temp.pageOffset = params.offset;
                    return temp;
                },
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '主键',
                    align: 'center',
                    visible: false
                },
                {
                    field: 'storeImage',
                    align: 'center',
                    title: '店铺门头',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'storeName',
                    align: 'center',
                    title: '店铺名称'
                },
                {
                    field: 'storePageviews',
                    align: 'center',
                    title: '店铺浏览量'
                },
                {
                    field: 'storeAddress',
                    align: 'center',
                    title: '详细地址'
                },
                {
                    field: 'storePerson',
                    align: 'center',
                    title: '店铺联系人'
                },
                {
                    field: 'storePhone',
                    align: 'center',
                    title: '店铺手机号'
                },
                {
                    field: 'storeBusinessHours',
                    align: 'center',
                    title: '营业时间'
                },
                {
                    field: 'storeOpenYears',
                    align: 'center',
                    title: '开业年限'
                },
                {
                    field: 'storeLicense',
                    align: 'center',
                    title: '营业执照',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },{
                        field: 'agentName',
                        align: 'center',
                        title: '所属大区'
                    },
                    {
                        field: 'isRaker',
                        align: 'center',
                        title: '是否订单管理人',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isRakerDatas, value);
                        }
                    },
                    {
                        field: 'isAppraisal',
                        align: 'center',
                        title: '配件鉴定权状态',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(partsCheckDatas, value);
                        }
                    },
                    {
                        field: 'isDiamond',
                        align: 'center',
                        title: '星级店铺',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isRakerDatas, value);
                        }
                    },
                {
                    field: 'storeStateName',
                    align: 'center',
                    title: '状态'
                },

                    {
                        field: 'createTime',
                        align: 'center',
                        title: '加入时间'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<div style="display: flex">');
                        if(row.isAppraisal == "1"){
                            actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" style="margin: 0 3px;" href="javascript:void(0)" onclick="closePartsCheck(\'' + row.id + '\')"><i class="fa fa-unlock-alt"></i>强制关闭鉴定权</a> ');
                        }
                        if(row.isAppraisal == "0"){
                            actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" style="margin: 0 3px;" href="javascript:void(0)" onclick="openPartsCheck(\'' + row.id + '\')"><i class="fa fa-unlock"></i>打开鉴定权</a> ');
                        }

                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '"  style="margin: 0 3px;" href="javascript:void(0)" onclick="viewRepairStore(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" style="margin: 0 3px;" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('</div>');
                        actions.push('<div style="display: flex;margin-top: 3px;">');
                        if(row.storeStateName == "待审核"){
                            actions.push('<a style="margin-left: 3px;background-color: white;border-color: orangered;color: orangered;font-weight: bolder" class="btn btn-info btn-xs \' + removeFlag + \'" href="javascript:void(0)" onclick="checkStore(\'' + row.id + '\')"><i class="fa fa-check"></i>去审核</a> ');
                        }else if(row.storeStateName == "通过"){
                            actions.push('<a style="margin-left: 3px;background-color: white;border-color: #ecbd06;color: #ecbd06;font-weight: bolder" class="btn btn-info btn-xs \' + removeFlag + \'" href="javascript:void(0)" onclick="updateStore(\'' + row.id + '\')"><i class="fa fa-check"></i>更改店铺类型</a> ');
                        }
                        if(row.isDiamond == "0"){
                            actions.push('<a style="margin-left: 3px;background-color: white;border-color: #402bff;color: #402bff;font-weight: bolder" class="btn btn-info btn-xs \' + removeFlag + \'" href="javascript:void(0)" onclick="topStore(\'' + row.id + '\')"><i class="fa fa-level-up"></i>设置星级店铺</a> ');
                        }else{
                            actions.push('<a style="margin-left: 3px;background-color: white;border-color: #ffa036;color: #ffa036;font-weight: bolder" class="btn btn-info btn-xs \' + removeFlag + \'" href="javascript:void(0)" onclick="cancleTopStore(\'' + row.id + '\')"><i class="fa fa-level-up"></i>取消星级店铺</a> ');
                        }
                        actions.push('</div>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function viewRepairStore(id) {
            var url = ctx+"zsyh/repairStore/viewRepairStore/"+id;
            layer.open({
                type: 2,
                area: ['1200px', '800px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看详情",
                content:  url,
                closeBtn: 1,
                // 弹层外区域关闭
                shadeClose: true,
                end: function(){
                    //location.reload();
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function closePartsCheck(id) {
            $.modal.confirm("确认要强制关闭该店铺鉴定权吗？", function() {
                $.operate.post(prefix + "/closePartsCheck", { "id":id,"type":"1"});
            })
        }

        function openPartsCheck(id) {
            $.modal.confirm("确认要打开该店铺鉴定权吗？", function() {
                $.operate.post(prefix + "/closePartsCheck", { "id":id,"type":"2"});
            })
        }

        function checkStore(id) {
            var url = ctx+"zsyh/repairStore/checkStore/"+id;
            layer.open({
                type: 2,
                area: ['1200px', '800px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "审核店铺",
                content:  url,
                /*closeBtn: 1,*/
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(){
                    $.modal.alertWarning("审核完成");
                    var $tableFlows = $('#bootstrap-table');
                    var pg = $tableFlows.bootstrapTable('getOptions').pageNumber;  //获取当前页码
                    // 跳转到对应的页面
                    $tableFlows.bootstrapTable('selectPage', parseInt(pg));
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function updateStore(id) {
            var url = ctx+"zsyh/repairStore/updateStore/"+id;
            layer.open({
                type: 2,
                area: ['500px', '300px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "更改店铺类型",
                content:  url,
                /*closeBtn: 1,*/
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(){
                    $.modal.alertWarning("更改完成");
                    var $tableFlows = $('#bootstrap-table');
                    var pg = $tableFlows.bootstrapTable('getOptions').pageNumber;  //获取当前页码
                    // 跳转到对应的页面
                    $tableFlows.bootstrapTable('selectPage', parseInt(pg));
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function topStore(id) {
            $.modal.confirm("确认要设置该店铺为星级店铺？", function() {
                $.operate.post(ctx+"zsyh/repairStore/topStore", { "id":id,"value":"1"});
            });
        }

        function cancleTopStore(id) {
            $.modal.confirm("确认要取消该店铺的星级标识吗？", function() {
                $.operate.post(ctx+"zsyh/repairStore/topStore", { "id":id,"value":"0"});
            });
        }

    </script>
</body>
</html>